

from concurrent.futures import thread
import re 

# re.match()函数

print(re.match('www','www.runoob.com').span())
print(re.match('com','www.rouoob.com'))


import re 

line = 'Dogs are smart than cats'

matchOBJ = re.match(r'(.*) are (.*?).*',line,re.M|re.I)

if matchOBJ:
    print('matchOBJ.group() :',matchOBJ.group())
    print('matchOBJ.group(1) :',matchOBJ.group(1))
    print('matchOBJ.group(2) :',matchOBJ.group(2))
else:
    print('Not Match!')


# re.match与re.search的区别
# re.match 只匹配字符串的开始，如果字符串开始不符合正则表达式，则匹配失败，函数返回 None，而 re.search 匹配整个字符串，直到找到一个匹配。

import re 

line = 'Dogs are smart than cats'

matchObj = re.search(r'dogs',line,re.M|re.I)

if matchObj:
    print('rearch -- matchObj.group',matchObj.group())
else:
    print('Not Search!')


if matchObj:
    # print('reach -- matchObj.group',matchObj.group(1))
    print('are you think cat than dog smart')

else:
    print('console.log')

print('')
if matchObj:
    def change_number():
        for i in range(100):
            i += 1
            if i < 50:
                i = i*5
                print(i,type(i),end='')
            else:
                print(i,end='')
    
    change_number()

import cgi,cgitb

form = cgi.FieldStorage()

if form.getvalue('drop'):
    droppValue = form.getvalue('drop')
else:
    print('Error!')
    
print('string\n')


# import 


### 进程部分
import threading
import time

exitFlag = 0

class myThread(threading.Thread):
    def __init__(self,threadID,name,delay):
        threading.Thread.__init__(self)
        self.threadID = threadID
        self.name = name
        self.delay = delay
    def run(self):
        print('run threading'+ self.name)
        print_time(self.name,self.delay,5)
        print('over threading'+self.name)
def print_time(threadName,delay,counter):
    while counter:
        if exitFlag:
            threadName.exit()
        time.sleep(delay)
        print('%s : %s'%(threadName,time.ctime(time.time())))
        counter -= 1
# 创建新进程
thread1 = myThread(1,'Thread-1',1)
thread2 = myThread(2,'Thread-2',2)
# 开启新进程
thread1.start()
thread2.start()
thread1.join()
thread2.join()
print('\n Over main thread')

for i in range(8,18):
    print(i)


import json

dict = {
    '0': '1',
    'hello': 'word',
    'url': 'http://www.baidu.com'
}

json_str = json.dumps(dict)

import os

list = ['ab','d','myload','but']
list.append('f')
print(list,type(list))
del list
print('second print list',list)


# 新函数
def newFun():
    a = ['mychart']
    a.append('yes')
    # json(a)
    print(a)

newFun()

def func_second(self,mage,num):
    # self.mage = mage
    # self.num = num
    mage = 12
    num = 9
    a = mage + num
    for i in range(10):
        print(i,type(i))
        # newlist = i
        if i.bit_length < 10:
            print('prin value is true')
 
func_second(10,2,5)

